package cn.itcast.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum GenderEnum {
    MALE(1, "男"),
    FEMALE(2, "女");
    
    private final Integer code;
    private final String desc;

    // GenderEnum.java
    public static Integer getCodeByDesc(String desc) {
        if (desc == null) return null;
        for (GenderEnum value : values()) {
            if (value.desc.equals(desc.trim())) {
                return value.code;
            }
        }
        return null; // 或者抛出异常
    }

}

